package cn.dengta.webapp.user.entity;

import java.util.Date;

import cn.dengta.common.model.ValueProxy;
import cn.dengta.common.model.ValueProxyImpl;
import cn.dengta.webapp.base.entity.BizEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.StringUtil;
import me.codeplayer.util.X;

/**
 * 白名单
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("dt_user_white_account")
public class UserWhiteAccount extends BizEntity {

	/** 用户id */
	private Long userId;
	/** 类型 */
	private Integer type;
	/** 类型id */
	private Long businessId;
	/** 备注 */
	private String remark;

	public UserWhiteAccount init(UserWhiteAccount input, Date now) {
		this.userId = X.expectNotNull(input.userId, userId);
		this.type = X.expectNotNull(input.type, type);
		this.remark = StringUtil.toString(input.remark);
		super.initTime(now);
		super.init(input.status, input.state);
		return this;
	}

	public UserWhiteAccount init(Long userId, Integer type, Date now) {
		this.userId = userId;
		this.type = type;
		super.initTime(now);
		super.initActiveStatus();
		return this;
	}

	@Getter
	public enum UserWhiteAccountType implements ValueProxyImpl<UserWhiteAccountType, Integer> {
		/** 登录IP */
		IP(0, "IP"),
		/** 主播补贴名单 */
		ANCHOR_ASSESS(1, "主播补贴名单"),
		/** 支付宝白名单 */
		ALIPAY_CASH(2, "支付宝白名单"),
		/** 线下女主播 */
		OFFLINE_ANCHOR(3, "线下女主播"),
		/** 中文女主播 */
		CN_ANCHOR(4, "中文女主播"),
		/** 倾向付费 */
		BIASED_PAY(5, "VIP陪聊"),
		/** 用户每日充值限制 */
		DAY_RECHARGE(6, "每日充值");

		public Integer value;
		final ValueProxy<UserWhiteAccountType, Integer> proxy;

		UserWhiteAccountType(Integer value, String label) {
			this.value = value;
			this.proxy = new ValueProxy<>(this, value, label);
		}

		public static final UserWhiteAccountType[] CACHE = values();

		public static UserWhiteAccountType of(Integer value) {
			return IP.getValueOf(value);
		}

	}

	public static final String USER_ID = "user_id";
	public static final String TYPE = "type";
	public static final String BUSINESS_ID = "business_id";


}
